package ml.kupin.portal.controller;

import ml.kupin.pojo.TbContent;
import ml.kupin.content.service.ContentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * Created by 小柯(Allen Kerr) on 17.4.26 17:10.
 */
@Controller
public class IndexController {

    @Autowired
    private ContentService contentService;

    @Value("${ad_wheel_image_cid}")
    private long ad_wheel_image_cid;


    /**
     * 返回首页
     *
     * @return
     */
    @RequestMapping("/index")
    public String showIndexPage(Model model) {
        //获取轮播图内容集合
        List<TbContent> wheelImageContents = contentService.getContentsBycategoryId(ad_wheel_image_cid);
        //放入model中
        model.addAttribute("ad1List", wheelImageContents);


        //返回首页 WEB-INF/jsp/index.jsp
        return "index";
    }

}
